﻿using Newtonsoft.Json;
using Service.src.NW.Model.Enum;
using SqlSugar;
using SqlSugar.DbConvert;

namespace Service.src.NW.Model
{
    [SugarTable("sys_event")]
    public class SystemEvent : BaseEntity
    {

        [SugarColumn(ColumnName = "trigger_device")]
        public string TriggerDevice { get; set; }

        [SugarColumn(ColumnName = "event_name")]
        public string EventName { get; set; }

        [SugarColumn(ColumnName = "trigger_id")]
        public int TriggerId { get; set; }

        /// <summary>
        /// 触发模式:
        /// 
        /// 值变化
        /// 值相等
        /// </summary>
        [SugarColumn(ColumnName = "trigger_mode", SqlParameterDbType = typeof(EnumToStringConvert))]
        [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] // 添加此特性
        public TriggerModeEnum? TriggerMode { get; set; }

        [SugarColumn(ColumnName = "trigger_value")]
        public string TriggerValue { get; set; }

        [SugarColumn(ColumnName = "trigger_source")]
        public string TriggerSource { get; set; }

        [SugarColumn(ColumnName = "trigger_source_id")]
        public int TriggerSourceId { get; set; }

        /// <summary>
        /// 触发的流程id
        /// </summary>
        [SugarColumn(ColumnName = "trigger_flow")]
        public long TriggerFlow { get; set; }

        /// <summary>
        /// 触发的流程名称
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string TriggerName { get; set; }

        /// <summary>
        /// 上传的触发值
        /// </summary>
        [SugarColumn(IsIgnore = true)]
        public string BeforeTriggerValue { get; set; }
    }
}
